package com.company.woye.checkscan.adapte;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.company.woye.R;
import com.company.woye.checkscan.bean.AllPiece;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class CheckScanListviewAdapter extends BaseAdapter {

    private LayoutInflater inflater;
    private Context mContext;
    private List<AllPiece.DataBean> listBeans;

    public CheckScanListviewAdapter(Context context, List<AllPiece.DataBean> listBeans) {
        this.inflater = LayoutInflater.from(context);
        this.mContext = context;
        this.listBeans = listBeans;
    }

    @Override
    public int getCount() {
        return listBeans.size();
    }

    @Override
    public Object getItem(int position) {
        return listBeans.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHodler = null;
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.intem_start_stacn_detail, parent, false);
            viewHodler = new ViewHolder(convertView);
            convertView.setTag(viewHodler);
        } else {
            viewHodler = (ViewHolder) convertView.getTag();
        }
        AllPiece.DataBean dataBean = listBeans.get(position);
        viewHodler.tvCm.setText(dataBean.getCm());
        viewHodler.tvDbh.setText(dataBean.getDbh());
        viewHodler.tvHyh.setText(dataBean.getHyh());
        viewHodler.tvWcs.setText(dataBean.getShl()+"");

        viewHodler.tvGh.setText(dataBean.getGh());
        viewHodler.tvHh.setText(dataBean.getHh());
        viewHodler.tvPo.setText(dataBean.getPoh());
        viewHodler.tvSc.setText(dataBean.getSc());
        viewHodler.tvSh.setText(dataBean.getSh());
        viewHodler.tvSl.setText(dataBean.getShl() + "");
        return convertView;
    }


    class ViewHolder {
        @BindView(R.id.tv_dbh)
        TextView tvDbh;
        @BindView(R.id.tv_hyh)
        TextView tvHyh;
        @BindView(R.id.tv_cm)
        TextView tvCm;
        @BindView(R.id.tv_wcs)
        TextView tvWcs;
        @BindView(R.id.tv_gh)
        TextView tvGh;
        @BindView(R.id.tv_hh)
        TextView tvHh;
        @BindView(R.id.tv_po)
        TextView tvPo;
        @BindView(R.id.tv_sh)
        TextView tvSh;
        @BindView(R.id.tv_sc)
        TextView tvSc;
        @BindView(R.id.tv_sl)
        TextView tvSl;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
